package com.csmzxy.soft.comm;

import java.util.ArrayList;

public class Customer {
	private String name;
	private String idCard;
	private String telephone;
	private boolean isVip;
	private String Address;
	private ArrayList<Account> accountList;
	
	public Customer(String name,String idCard,String telephone){
		this.name=name;
		this.idCard=idCard;
		this.telephone=telephone;
	}
	public Customer(String name,String idCard,String telephone,String Address){
		this.name=name;
		this.idCard=idCard;
		this.telephone=telephone;
		this.Address=Address;
	}
	public String getTelephone() {
		return telephone;
	}
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	public String getIdCard() {
		return idCard;
	}
	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public boolean isVip() {
		return isVip;
	}
	public void setVip(boolean isVip) {
		this.isVip = isVip;
	}
	public String getAddress() {
		return Address;
	}
	public void setAddress(String address) {
		Address = address;
	}
	public String toString(){
		return "[姓名："+name+",身份证号："+idCard+",电话:"+telephone+"地址："+Address+",Vip:"+isVip+"]";
	}
	public ArrayList<Account> getAccountList() {
		return accountList;
	}
	public void setAccountList(ArrayList<Account> accountList) {
		this.accountList = accountList;
	}
	public void addAccount(Account account){
		if(accountList==null){
			accountList=new ArrayList<Account>();
			if(getAccount(account.getId())==null){
				this.accountList.add(account);
			}
		}
	}
	public void delAccount(String accId){
		for(Account acc:accountList){
			if(acc.getId().compareTo(accId)==0){
				
				this.accountList.remove(acc);
				break;
			}
		}
	}
	public Account findAccount(int i){
		return this.accountList.get(i);
	}
	public void modifyAccount(int i,Account account){
		this.accountList.set(i, account);
	}
	public Account getAccount(String accId){
		for(Account acc:accountList){
			if(acc.getId().compareTo(accId)==0)
				return acc;
		}
		return null;
	}
}
